'use strict';

const RequestJsonApi = require('../lib/class/requestJsonApi');

module.exports = app => {
  // 定义参数 继承request类

  const host = app.config.apiServiceLocation.product;
  const url = '/snapshots';
  const dataType = 'snapshots';

  const productSnapshots = new ProductSnapshots({ host, url, dataType });

  return productSnapshots;
};

class ProductSnapshots {
  constructor (options) {
    this.requestJsonApi = new RequestJsonApi(options);
  }

  async get (idList) {
    // { idList: [1, 3, 5, 6, 7] }
    const includes = ['product', 'product.prices'];
    const data = await this.requestJsonApi.get({ idList, includes });
    return data;
  }
}
